<?php


namespace app\api\controller;

use app\common\controller\Api;
use think\Db;

/**
 * 公共接口
 */
class Listsorder extends Api
{
    protected $noNeedLogin = [''];
    protected $noNeedRight = '*';



    /**
     *  订单列表
     */
    public function getorderlist()
    {
        $uid=$this->auth->id;
        $status=$this->request->param('status',0);

        $list=Db::name('fworder')
            ->alias('a')
            ->join('goods c','a.goods_id=c.id')
            ->where('a.status','eq',$status)
            ->order('id desc')
            ->field('c.image,a.*,c.name as goodsname')
            ->select();



        foreach ($list as &$v){
            $v['image']=cdnurl($v['image'],true);
            $v['addtime']=date('Y-m-d H:i',$v['addtime']);
        }

        $this->success('订单列表',$list);


    }

    /**
     *  转换图片
     * zfimage` varchar(255) DEFAULT NULL COMMENT '支付宝收款码',
     * `zfsjimage` varchar(255) DEFAULT NULL COMMENT '支付宝商家码',
     * `payimage` varchar(255) DEFAULT NULL COMMENT '微信收款码',
     */

    /**
     *  修改订单
     *
     */
    public function setorerpayimg(){
        $id=$this->request->param('id',0);
        $payimg=$this->request->param('img','');

        $ret=Db::name('fworder')
            ->where('id',$id)
            ->update(['payimg'=>$payimg,'paytime'=>time(),'status'=>1]);

        if ($ret){
            $this->success('修改成功');
        }
        $this->error('修改失败');


    }




}